package yt.kpool.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.king.base.adapter.ViewHolderRecyclerAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.text.NumberFormat;
import java.util.List;

import yt.kpool.R;
import yt.kpool.activity.profit.ProfitDetailAc;
import yt.kpool.bean.ProfitBean;
import yt.kpool.util.Util;

public class ProfitAdapter extends ViewHolderRecyclerAdapter<ProfitBean.DataBean> {
    private Context contexts;
    private String DW;
    public ProfitAdapter(Activity context, List<ProfitBean.DataBean> listData) {
        super(context, listData);
        contexts = context;

    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, int viewType) {
        return layoutInflater.inflate(R.layout.adapter_profit, null);
    }

    @Override
    public void bindViewDatas(ViewHolder holder, final ProfitBean.DataBean dataBean, int position) {

        holder.setText(R.id.tv_time, dataBean.getProfitTime());
        TextView tv_sl=holder.getView(R.id.tv_sl);
        if(dataBean.getCurrencyCode().toUpperCase().equals(DW.toUpperCase()))
        {

            tv_sl.setText("平均算力："+dataBean.getHashrate24H());
            tv_sl.setTextColor(Color.parseColor("#aaaaaa"));
        }
        else
        {
            tv_sl.setText("联合挖矿");
            tv_sl.setTextColor(Color.parseColor("#3862db"));
        }

        NumberFormat format=NumberFormat.getNumberInstance();
        format.setMaximumFractionDigits(20);
//        holder.setText(R.id.tv_price, format.format(dataBean.getAmount())+" "+DW.toUpperCase());
        holder.setText(R.id.tv_price, format.format(dataBean.getAmount())+" "+dataBean.getCurrencyCode().toUpperCase());
        holder.setText(R.id.tv_state, dataBean.getState());
        holder.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ProfitDetailAc.start(context,dataBean,DW);
            }
        });
    }


  public void setDw(String DWS)
  {
      DW=DWS;
  }
}
